import 'package:flutter/material.dart';
import 'package:fluwx/fluwx.dart';

class WeShare extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return ShareState();
  }
}

class ShareState extends State<WeShare> {
  ///[WeChatScene.SESSION]会话
  ///[WeChatScene.TIMELINE]朋友圈
  ///[WeChatScene.FAVORITE]收藏

  // String _imagePath =
  //     'https://imgcdn.huanjutang.com/file/2021/01/15/642729fc39a474e6a9440bdca5bf6af2.png';

  Widget build(BuildContext context) {
    return Container(
      child: Flex(
        direction: Axis.vertical,
        children: [
          TextButton(
            child: Text(
              '分享好友',
              style: TextStyle(color: Colors.white),
            ),
            onPressed: () {
              print('分享好友');
              shareToWeChat(
                WeChatShareTextModel(
                  "source text",
                  scene: WeChatScene.SESSION,
                ),
              ).then((data) {
                print(data);
              });
            },
            style: ButtonStyle(
              backgroundColor: MaterialStateProperty.all(Colors.pink),
              minimumSize: MaterialStateProperty.all(Size(300, 50)),
            ),
          ),
          Container(
            child: TextButton(
              child: Text(
                '分享朋友圈',
                style: TextStyle(color: Colors.white),
              ),
              onPressed: () {
                print('分享朋友圈');
                shareToWeChat(
                  WeChatShareTextModel(
                    "source text",
                    scene: WeChatScene.TIMELINE,
                  ),
                ).then((data) {
                  print(data);
                });
              },
              style: ButtonStyle(
                backgroundColor: MaterialStateProperty.all(Colors.orange),
                minimumSize: MaterialStateProperty.all(Size(300, 50)),
              ),
            ),
            margin: EdgeInsets.only(top: 30),
          ),
          Container(
            child: TextButton(
              child: Text(
                '分享小程序',
                style: TextStyle(color: Colors.white),
              ),
              onPressed: () {
                print('分享小程序');
                var model = WeChatShareMiniProgramModel(
                    webPageUrl: 'http://www.qq.com',
                    userName: 'gh_b342a34f1d40',
                    title: '成都房小团',
                    path: '/pages/index',
                    description: '成都房小团',
                    thumbnail: WeChatImage.network(
                        'https://imgcdn.huanjutang.com/file/2021/01/15/642729fc39a474e6a9440bdca5bf6af2.png'));
                shareToWeChat(model);
              },
              style: ButtonStyle(
                backgroundColor: MaterialStateProperty.all(Colors.orange),
                minimumSize: MaterialStateProperty.all(Size(300, 50)),
              ),
            ),
            margin: EdgeInsets.only(top: 30),
          )
        ],
      ),
      padding: EdgeInsets.only(top: 50),
    );
  }
}
